#pragma once
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>


typedef char BTDateType;

typedef struct BinaryTreeNode
{
	BTDateType date;
	struct BinaryTreeNode* left;
	struct BinaryTreeNode* right;
}BTNode;

//通过前序遍历的数组"ABD##E#H##CF##G##"构建二叉树
BTNode* BinaryTreeCreate(BTDateType* a, int n, int* pi);
void BinaryTreeDestroy(BTNode* root);

int BinaryTreeSize(BTNode* root);//二叉数节点的个数
int BinaryTreeLeafSize(BTNode* root);//二叉树叶子节点的个数
int BinaryTreeLevelKSize(BTNode* root, int k);//二叉树第k层节点的个数

BTNode* BinaryTreeFind(BTNode* root, BTDateType x);//二叉树查找值为x的节点

void BinaryTreePrevOrder(BTNode* root);//前中后序遍历
void BinaryTreeInOrder(BTNode* root);
void BinaryTreePostOrder(BTNode* root);

void BinaryTreeLevelOrder(BTNode* root);//层序遍历

int BinaryTreeComplete(BTNode* root);



//队列的部分
typedef BTNode* Qdatetype;

typedef struct QueueNode
{
	struct QueueNode* next;
	Qdatetype date;
}QueueNode;

typedef struct Queue
{
	QueueNode* head;
	QueueNode* tail;
	int size;
}Queue;

void QueueInit(Queue* qp);
void QueueDestory(Queue* qp);
void QueuePush(Queue* qp, Qdatetype x);
void QueuePop(Queue* qp);
int QueueSize(Queue* qp);
int QueueEmpty(Queue* qp);
Qdatetype QueueFront(Queue* qp);
Qdatetype QueueBack(Queue* qp);